#include<bits/stdc++.h>

using namespace std;
namespace cp {
    struct Uncomment {
        vector<string> lines;

        Uncomment(const string filename) {
            ifstream fin(filename);
            for (string line; getline(fin, line);) {
                lines.push_back(line);
                //cerr << line << endl;
            }
        }

        void uncomment_cpp_comments() {
            for (auto &line :lines) {
                auto pos = line.find("//");
                if (pos == string::npos)
                    continue;
                else {
                    cerr << "// comments found at" << line << endl;
                    line = line.substr(0, pos);
                }
            }
        }

        void uncomment_C_comments() {
            int start_line = 0, start_pos = 0;
            int end_line = 0, end_pos = 0;
            while (true) {
                bool has_c_comments = false;
                for (int i = start_line; i < lines.size(); i++) {
                    auto pos = lines[i].find("/*");
                    if (pos != string::npos) {
                        start_line = i;
                        start_pos = pos;
                        has_c_comments = true;
                        break;
                    }
                }
                if (has_c_comments) {
                    for (int i = start_line; i < lines.size(); i++) {
                        auto pos = lines[i].find("*/");
                        if (pos != string::npos) {
                            end_line = i;
                            end_pos = pos + 2;
                            break;
                        }
                    }
                    cerr << "/**/ comments found at start_line=" << start_line << "end_line=" << end_line << endl;
                    if (start_line != end_line) {
                        lines[start_line] = lines[start_line].substr(0, start_pos);
                        for (int i = start_line + 1; i < end_line; i++) {
                            lines[i] = "";
                        }
                        lines[end_line] = lines[end_line].substr(end_pos);
                    } else {
                        lines[start_line] = lines[start_line].substr(0, start_pos) + lines[start_line].substr(end_pos);
                        cerr << "line:" << start_line << ":" << lines[start_line] << endl;
                    }
                }
                if (!has_c_comments)break;
            }
        }

        void show_code(bool show_line_number = false) {
            int line_number = 0;
            for (const string line:lines) {
                if (line.size()) {
                    cout << fixed << setw(3) << ++line_number << ": ";
                    cout << line << endl;
                }
            }
        }
    };
}

int main() {
    string filename("test.cpp");
    cp::Uncomment uc(filename);

    uc.uncomment_cpp_comments();
    uc.uncomment_C_comments();

    uc.show_code();

}